//=============================================================================
// PlasmaGunAltFire.
//=============================================================================
class PlasmaGunAltFire extends LinkAltFire; //ProjectileFire;

//var sound LinkedFireSound;
//var string LinkedFireForce;  // jdf


function DrawMuzzleFlash(Canvas Canvas)
{
    if (FlashEmitter != none && weapon!=none)
    {
        FlashEmitter.SetRotation(Weapon(Owner).Rotation);
        Super.DrawMuzzleFlash(Canvas);
    }
}

event ModeDoFire()
{
    Recoil();
    Super.ModeDoFire();
}

function Projectile SpawnProjectile(Vector Start, Rotator Dir)
{
    local PlasmaGunProjectile Proj;

    Start += Vector(Dir) * 10.0 * LinkGun(Weapon).Links;
    Proj = Spawn(class'PlasmaGunProjectile',,, Start, Dir);
    if (Proj != None && Weapon!=none && LinkGun(Weapon)!=none)
    {
		Proj.Links = LinkGun(Weapon).Links;
		Proj.LinkAdjust();
	}
//    Recoil();

    return Proj;
}

function FlashMuzzleFlash()
{
    if (FlashEmitter != None)
    {
//        if (LinkGun(Weapon).Links > 0)
//            FlashEmitter.Skins[0] = FinalBlend'TFMedia.Plasma_Muz_blueFB';
//        else
            FlashEmitter.Skins[0] = FinalBlend'TFMedia.Plasma_Muz_blueFB';
    }
    Super.FlashMuzzleFlash();
}

function ServerPlayFiring()
{
//    if (LinkGun(Weapon).Links > 0)
//        FireSound = LinkedFireSound;
//    else
        FireSound = default.FireSound;
    Super.ServerPlayFiring();
}

function PlayFiring()
{
//    if (LinkGun(Weapon).Links > 0)
//        FireSound = LinkedFireSound;
//    else
FireSound = default.FireSound;
    Super.PlayFiring();
}

simulated function ModeTick(float dt)
{
if (FlashEmitter != None)
    {
    FlashEmitter.Skins[0] = FinalBlend'TFMedia.PlasmaMuzProjBlueFB';
    }
}

function Recoil()
{
    local Rotator NewRotation;
    local float NewPitch, NewYaw;

    if ( (Instigator != None) && Instigator.IsFirstPerson()){
    NewPitch = int(Frand()*75); NewYaw = int(Frand()*125);
    if (Frand() > 0.5) NewYaw *= -1;
    if (Frand() > 0.5) NewPitch *= -1;
    NewRotation = Instigator.GetViewRotation();
    NewRotation.Pitch += NewPitch;
    NewRotation.Yaw += NewYaw;
    Instigator.SetViewRotation(NewRotation);}
}

defaultproperties
{
     FireSound=Sound'IntroSounds.fX.HitButton1'
     FireRate=0.050000
     AmmoClass=Class'Taskforces.PlasmaGunAmmo'
     ProjectileClass=Class'Taskforces.PlasmaGunProjectile'
     FlashEmitterClass=Class'Taskforces.PlasmaMuzFlashProj1st'
}
